import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_appgetwe/wiget/video_player_item.dart';
import 'package:video_player/video_player.dart';

class RouteItem{
  String id;

  RouteItem(this.id);
}
class DetailVideoIndex extends StatefulWidget {


  @override
  _DetailVideoIndexState createState() => _DetailVideoIndexState();
}

class _DetailVideoIndexState extends State<DetailVideoIndex> {

  bool isLike = false;

  bool isfollow = true;

  bool isPlay = true;

  List<Map> mapList = [];

  @override
  void initState() {

    // TODO: implement initState
    super.initState();
    for (int i = 0; i < 20; i++) {
      mapList.add({
        "videoUrl": "https://gubanjie-1302851887.cos.ap-guangzhou.myqcloud.com/video/16.mp4",
        "id": i,
        "like": 500 + i,
        "common": 20 + i,
        "fellow": 50 + i,
      });
    }
  }

  @override
  Widget build(BuildContext context) {
   // Map teacherMap = ModalRoute.of(context)?.settings.arguments;
    print("打印路由........");
    print(ModalRoute.of(context)?.settings.arguments.toString());
    Object? maps = ModalRoute.of(context)?.settings.arguments;
    print(maps.toString());
    return Scaffold(
      body: PageView.builder(
          itemCount: 23,
          controller: PageController(initialPage: 0, viewportFraction: 1),
          scrollDirection: Axis.vertical,
          itemBuilder: (context, index) {
            if (index > mapList.length - 5) {
              _showVideoList();
            }
            return Stack(
              children: [
                VideoPlayerItem(
                    videoUrl: "https://gubanjie-1302851887.cos.ap-guangzhou.myqcloud.com/video/16.mp4",
                    isPlayFunction: () {},
                    isPlay: true),
                Positioned(
                  bottom: 70,
                  left: 20,
                  child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        SizedBox(
                          height: 3,
                        ),
                        Container(
                          child: Text(
                            "rivaanranawat",
                            style: TextStyle(
                                fontSize: 20, fontWeight: FontWeight.w600),
                          ),
                        ),
                        SizedBox(
                          height: 3,
                        ),
                        Container(
                          child: Text(
                            "No Song, Only Tript",
                            style: TextStyle(fontSize: 16),
                          ),
                        ),
                        SizedBox(
                          height: 3,
                        ),
                        Row(
                          children: [
                            Icon(
                              Icons.music_note,
                              size: 16,
                            ),
                            Text(
                              "IDK",
                              style: TextStyle(
                                  fontSize: 16, fontWeight: FontWeight.w600),
                            ),
                          ],
                        )
                      ]),
                ),
                Positioned(
                    right: 20,
                    bottom: 150,
                    child: Column(
                      children: [
                        Stack(
                          alignment: Alignment.center,
                          children: [
                            Container(
                              height: 60,
                              width: 60,
                              //color: Colors.blue,
                            ),
                            Container(
                              width: 40,
                              height: 40,
                              decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(40),
                                  image: DecorationImage(
                                    image: NetworkImage(
                                        "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F202105%2F29%2F20210529001057_aSeLB.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1659189274&t=79ca0cb6236830ee1b7f343efc6f5824"),
                                    // fit: BoxFit.fill,
                                    colorFilter: ColorFilter.mode(
                                        Colors.black.withOpacity(0.2),
                                        BlendMode.darken),
                                  )),
                            ),
                            Positioned(
                              bottom: 1,
                              width: 20,
                              height: 20,
                              child: InkWell(
                                onTap: () {
                                  print("dianji..");
                                  setState(() {
                                    isfollow = !isfollow;
                                  });
                                },
                                child: isfollow ? Container(
                                  width: 20,
                                  height: 20,
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(20),
                                      color: Colors.red[300]),
                                ):Text(""),
                              ),
                            ),
                            Positioned(
                              bottom: 1,
                              child: Container(
                                child: Text(
                                  isfollow?"+":"",
                                  style: TextStyle(fontSize: 18),
                                ),
                              ),
                            )
                          ],
                        ),
                        SizedBox(
                          height: 10,
                        ),
                        Column(
                          children: [
                            InkWell(
                              onTap: () {
                                print("喜欢");
                                setState(() {
                                  isLike = !isLike;
                                });
                              },
                              child: Container(
                                margin: EdgeInsets.only(bottom: 3),
                                child: Icon(
                                  Icons.favorite,
                                  color: isLike ? Colors.red : Colors.white,
                                  size: 30,
                                ),
                              ),
                            ),
                            Text(mapList[index]["like"].toString() + ""),
                          ],
                        ),
                        SizedBox(
                          height: 20,
                        ),
                        Column(
                          children: [
                            InkWell(
                                onTap: () {
                                  print("评论");
                                },
                                child: Container(
                                  margin: EdgeInsets.only(bottom: 3),
                                  child: Icon(
                                    Icons.comment_rounded,
                                    color: Colors.white,
                                    size: 30,
                                  ),
                                )),
                            Text(mapList[index]["common"].toString() + ""),
                          ],
                        ),
                        SizedBox(
                          height: 20,
                        ),
                        Column(
                          children: [
                            InkWell(
                                onTap: () {
                                  print("分享");
                                },
                                child: Container(
                                  margin: EdgeInsets.only(bottom: 3),
                                  child: Icon(
                                    Icons.replay,
                                    color: Colors.white,
                                    size: 30,
                                  ),
                                )),
                            Text(mapList[index]["fellow"].toString() + ""),
                          ],
                        )
                      ],
                    )),
              ],
            );
          }),
    );
  }

  void _showVideoList() {
    for (int i = 0; i < 20; i++) {
      mapList.add({
        "videoUrl": "https://gubanjie-1302851887.cos.ap-guangzhou.myqcloud.com/video/16.mp4",
        "id": i,
        "like": 500 + i,
        "common": 20 + i,
        "fellow": 50 + i,
      });
    }
  }
}
